package com.woniuxy.company5.service.impl;

import com.woniuxy.company5.dto.LMacIoDto;
import com.woniuxy.company5.dto.MacIoDto;
import com.woniuxy.company5.dto.macListDto;
import com.woniuxy.company5.entity.MacIo;
import com.woniuxy.company5.entity.MacList;
import com.woniuxy.company5.mapper.MacIoMapper;
import com.woniuxy.company5.mapper.MacListMapper;
import com.woniuxy.company5.service.MacIoService;

import com.woniuxy.company5.vo.LMacIoVo;
import com.woniuxy.company5.vo.MacInformationVo;
import com.woniuxy.company5.vo.MacIoVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.crypto.Mac;
import java.util.Date;
import java.util.List;

@Service
public class MacIoServiceImpl implements MacIoService {

    @Resource
    private MacListMapper macListMapper;
    @Resource
    private MacIoMapper macIoMapper;

    @Override
    public List<LMacIoVo> selectByLike(LMacIoDto macIoDto) {
        return macIoMapper.selectByLike(macIoDto);
    }

    @Override
    public List<MacIoVo> selAllMacIo(MacIoDto macIoDto) {
        return macIoMapper.selAllMavIo(macIoDto);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insert(MacIo record) {
        return 0;
    }

    @Override
    public int insertSelective(MacIo record) {
        return macIoMapper.insertSelective(record);
    }

    @Override
    public MacIo selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(MacIo record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(MacIo record) {
        return 0;
    }

    @Override
    @Transactional
    public int chuKuService(macListDto macInformationVo) {

        macListMapper.updateBymaciId(macInformationVo.getMacId(),macInformationVo.getInventroy() - macInformationVo.getInventroy1());

        MacIo macIo = new MacIo();
        macIo.setEmpId(macInformationVo.getEmpId());
        macIo.setNum(macInformationVo.getGongDanId());
        macIo.setType(macInformationVo.getMacWhy());
        macIo.setInformationId(macInformationVo.getMacId());
        macIo.setOutDate(new Date());
        int i = macIoMapper.insertSelective(macIo);
        return i;
    }
}
